package software.agileCourse2013.KillerGame.web.Servlet;

import java.io.IOException;
import java.util.Random;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginServlet extends HttpServlet{

	private static final long serialVersionUID = 7311257106651311058L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		resp.sendRedirect("login.jsp");
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		String name = req.getParameter("yhm");
		String password = req.getParameter("mm");
		System.out.println(name);
		System.out.println(password);
		Random r = new Random();
		int i = r.nextInt(100);
		req.setAttribute("flag", "haha"+i);
		req.setAttribute("userID", 1234567);
		RequestDispatcher dispatcher = req.getRequestDispatcher("/hall.jsp");
		dispatcher .forward(req, resp);
	}

}
